From 85bc6f4326e93f022d2eddee03c7ee007fc92766 Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Thu, 11 Jan 2007 16:36:46 +0000 Subject: [PATCH] [XEND] Fix broken block-configure. Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendDomainInfo.py | 31 ++++++++++++++----------- tools/python/xen/xend/server/blkif.py | 1 + 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 099302f573..f80c3f5be7 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -496,7 +496,7 @@ class XendDomainInfo: self._waitForDevice(dev_type, devid) return self.getDeviceController(dev_type).sxpr(devid) - def device_configure(self, dev_config, devid = None): + def device_configure(self, dev_sxp, devid = None): """Configure an existing device. @param dev_config: device configuration @@ -506,19 +506,24 @@ class XendDomainInfo: @return: Returns True if successfully updated device @rtype: boolean """ - deviceClass = sxp.name(dev_config) - - # look up uuid of the device - dev_control = self.getDeviceController(deviceClass) - dev_sxpr = dev_control.sxpr(devid) - dev_uuid = sxp.child_value(dev_sxpr, 'uuid') - if not dev_uuid: - return False - self.info.device_update(dev_uuid, dev_config) - dev_config_dict = self.info['devices'].get(dev_uuid) - if dev_config_dict: - dev_control.reconfigureDevice(devid, dev_config_dict[1]) + # convert device sxp to a dict + dev_class = sxp.name(dev_sxp) + dev_config = {} + for opt_val in dev_sxp[1:]: + try: + dev_config[opt_val[0]] = opt_val[1] + except IndexError: + pass + + # use DevController.reconfigureDevice to change device config + dev_control = self.getDeviceController(dev_class) + dev_uuid = dev_control.reconfigureDevice(devid, dev_config) + + # update XendConfig with new device info + if dev_uuid: + self.info.device_update(dev_uuid, dev_sxp) + return True def waitForDevices(self): diff --git a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py index 44d1a1e1ff..72a0787d93 100644 --- a/tools/python/xen/xend/server/blkif.py +++ b/tools/python/xen/xend/server/blkif.py @@ -101,6 +101,7 @@ class BlkifController(DevController): self.writeBackend(devid, 'type', new_back['type'], 'params', new_back['params']) + return new_back.get('uuid') else: raise VmError('Refusing to reconfigure device %s:%d to %s' % (self.deviceClass, devid, config)) -- 2.30.2